import request from '@/utils/request'

const api = {
  list: 'web/classes/list', // 列表
  myList: 'web/classes/my_list', // 我的
  disableClass: 'web/classes/disable', // 禁用
  enableClass: 'web/classes/enable', // 启用
  info: 'web/classes/detail', // 详情
  submit: 'web/classes/create'
}

export function getList (params = {}) {
  return request({
    url: api.list,
    method: 'post',
    params
  })
}

export function getMyList (params = {}) {
  return request({
    url: api.myList,
    method: 'post',
    params
  })
}

export function getInfo (params = {}) {
  return request({
    url: api.info,
    method: 'post',
    params
  })
}

// 禁用/启用班级
export function toggleClass (params = {}, flag) {
  return request({
    url: flag ? api.enableClass : api.disableClass,
    method: 'post',
    params
  })
}

// 创建/修改班级
export function submitClass (params = {}) {
  return request({
    url: api.submit,
    method: 'post',
    params
  })
}
